#include <cppunit/config/SourcePrefix.h>
#include "TestCalls.h"
#include <string>

void TestCalls::setUp() {
	calls = Calls();
	calls.addCalls(0, 1);
	calls.addCalls(0, 2);
	calls.addCalls(1, 2);
	calls.addCalls(2, 3);
	calls.addCalls(0, 4);
}

void TestCalls::tearDown() {
}

CPPUNIT_TEST_SUITE_REGISTRATION( TestCalls );

void TestCalls::testAddCalls(){
	int index1 = calls.addCalls(4,5);
	int index2 = calls.addCalls(5,6);

	CPPUNIT_ASSERT_EQUAL_MESSAGE("6th item added; index 5", 5, index1);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("7th item added; index 6", 6, index2);
}

void TestCalls::testGetCalls(){
	vector<pair<int,int>> anyany = calls.getCalls(ANYVALUE, ANYVALUE);
	int size = anyany.size();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("All results return", 5, size);

	vector<pair<int,int>> anynum = calls.getCalls(ANYVALUE, 4);
	size = anynum.size();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("Only (allowed) 1 result to be found", 1, size);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("One result (0,4)", 0, anynum.at(0).first);

	vector<pair<int,int>> numany = calls.getCalls(0, ANYVALUE);
	size = numany.size();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("3 results found", 3, size);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("first result (0,1)", 1, numany.at(0).second);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("second result (0,2)", 2, numany.at(1).second);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("third result (0,4)", 4, numany.at(2).second);

	vector<pair<int,int>> numnum = calls.getCalls(2, 3);
	size = numnum.size();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("1 result found", 1, size);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("one result (2,3)", 2, numnum.at(0).first);
	CPPUNIT_ASSERT_EQUAL_MESSAGE("one result (2,3)", 3, numnum.at(0).second);

	vector<pair<int,int>> none = calls.getCalls(1, 4);
	size = none.size();
	CPPUNIT_ASSERT_EQUAL_MESSAGE("no result found", 0, size);
}

void TestCalls::testGetCallsStar(){

}